<template>
  <div>
    <!-- 信息 -->
    <el-table :data="tableData" border stripe>
        <el-table-column type="selection" width="55"></el-table-column>
        <!-- <el-table-column prop="id" label="ID" width="80"></el-table-column> -->
        <el-table-column prop="tableName" index label="表名" width="60">
          <template slot-scope="scope">{{ scope.row }}</template>

        </el-table-column>

        <el-table-column label="操作"  width="200" align="center">
          <template v-slot="scope">
            <el-button type="success" @click="backup(scope.row)">备份 <i class="el-icon-document-add"></i></el-button>
              <el-button type="success" @click="rollback(scope.row)">恢复<i class="el-icon-edit"></i></el-button>
          </template>
        </el-table-column>
      </el-table>
      


  </div>

</template>

<script>
export default {
name: 'BackUp',
components: {
  // PageHelper
},
data () {
  return {
    tableData: [

    ], // 表名集合
    currentNo: 1,
    pageSize: 10,
    total: 0,
    // tableName: ''

  }
},

methods: {
  show () {
    this.request.get('backup/show', { params: { currentNo: this.currentNo, pageSize: this.pageSize} }).then(res => {
      
      console.log(res)
      // let obj = res.data.list
      this.tableData = res.data.list
      // console.log(this.data)
      // console.log(obj)
      
    })
  },
  getPageSize (val) {
    this.pageSize = val
    this.getAll()
  },
  getCurrent (val) {
    this.currentNo = val
    this.getAll()
  },
  backup (row){
    console.log(row)

        this.request.get('backup/mysqlBackups/'+row).then(res => {
          console.log(tableName)
          this.$message({
      message: '恭喜你,备份成功',
      type: 'success'
      })
        //   if (res.code === '200'){
        //     this.$message.success("备份成功")
        //     this.load()
        //   }else {
        //     this.$message.error("备份失败")
        //   }
        })
      },
  rollback (row){
    console.log(row)

        this.request.get('backup/rollback/'+row).then(res => {
          console.log(tableName)
          this.$message({
      message: '恭喜你,恢复成功',
      type: 'success'
      })
        //   if (res.code === '200'){
        //     this.$message.success("备份成功")
        //     this.load()
        //   }else {
        //     this.$message.error("备份失败")
        //   }
        })
      },    
},

mounted () {
  this.show()
}
}
</script>
<style>
.el-table .warning-row {
background: #74cdea;

}

.el-table .success-row {
background: #f0f9eb;
}
li{
list-style: none;
}

</style>
